<?php
	session_start();
	require_once('common/config.php');
	
	$login_OK = true;
	if(isset($_POST['submit']))
	{
		if( ($_POST['username'] == USER_ADMIN && $_POST['password']== PASS_ADMIN) || 
			($_POST['username'] == USER_PRODUCT && $_POST['password']== PASS_PRODUCT) ||
			($_POST['username'] == USER_ORDER && $_POST['password']== PASS_ORDER) )
		{
			$_SESSION['logon'] = true;
			$_SESSION['user'] = $_POST['username'];
			$login_OK = true;
			
			if(!isset($_GET['url']))
				$_GET['url'] ='index';

			header("Location: /wks/{$_GET['url']}.php");
			exit();
		}
		else
		{
			$login_OK = false;
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0063)#contact -->
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title>WKS</title>
	<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      .sidebar-nav {
        padding: 9px 0;
      }
    </style>
  </head>

  <body>

    <form class="well form-inline" action="/wks/login.php" method="post">
		<?php 
			if(!$login_OK)
			{
				echo "<h2><span class=\"label label-warning\">Warning</span> Đăng nhập lại </h2>\n";

			}
		?>
	  <input type="text" class="input-small" placeholder="Username" name="username">
	  <input type="password" class="input-small" placeholder="Password" name="password">
	  <!--<label class="checkbox">
	    <input type="checkbox"> Remember me
	  </label>-->
	  <button type="submit" class="btn" name="submit">Sign in</button>
	</form>
</body>
</html>